package players;
import staticClasses.*;


public class Agent extends Thread{
	
	protected int[] position = new int[2];
	
	/**
	 * run method from Runnable interface.
	 * Don't forget to Override it with @override
	 * in the extending classes
	 */
	public void run(){}
	
	/**
	 * This method will move the specified Agent in the given direction.
	 * @param dir The direction to move to.
	 * @throws Exception If a wrong parameter is given
	 */
	public void move(Direction dir) throws Exception{
		switch(dir){
		case NORTH:
			this.position[1]++;
			break;
		case SOUTH:
			this.position[1]--;
			break;
		case EAST:
			this.position[0]++;
			break;
		case WEST:
			this.position[0]--;
			break;
		case NORTH_EAST:
			this.position[1]++;
			this.position[0]++;
			break;
		case NORTH_WEST:
			this.position[1]++;
			this.position[0]--;
			break;
		case SOUTH_EAST:
			this.position[1]--;
			this.position[0]++;
			break;
		case SOUTH_WAST:
			this.position[1]--;
			this.position[0]--;
			break;
		default:
			throw(new Exception("Unknown direction"));
		}
	}
	
	/*
	 * *********************************
	 * GETTERS AND SETTERS
	 * *********************************
	 */
	
	/**
	 * Set the position of the Agent
	 * @param x axis x (horizontal)
	 * @param y axis y (vertical)
	 * @return 
	 */
	public synchronized void setPosition(int x, int y){
		this.position[0] = x;
		this.position[1] = y;
	}
	
	/**
	 * Return a 2-element array containing x and y axis of an Agent
	 * First argument is x and second argument is y
	 * @return the position of the Agent
	 */
	public synchronized int[] getPosition(){
		return this.position;
	}
}
